package eight.test_8_10;

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int k = scanner.nextInt();
        int[] arr = new int[n];
        int[] hash1 = new int[n];
        int[] hash2 = new int[n];
        Set<Integer> set = new HashSet<>();
        for (int i = 0; i < n; i++) {
            int tmp = scanner.nextInt();
            set.add(tmp);
            hash1[i] = set.size();
        }

        int left = 0;
        int right = n;
        scanner.nextLine();
        for (int i = 0; i < n; i++) {
            String str = scanner.nextLine();
            char c = str.charAt(0);
            String tmp = str.substring(2);
            int x = Integer.valueOf(tmp);
            if(x >= n) {
                System.out.println(hash1[n - 1]);
            } else {
                if(c == 'L') {
                    System.out.println(hash1[x - 1]);
                } else {
                    System.out.println(hash2[n - x]);
                }
            }
        }
    }
}
